package com.hllxd.hism.star.basic.service.service;

import com.alibaba.fastjson.JSON;
import com.hllxd.hism.star.basic.service.dao.mapper.mis.SpmMapper;
import com.hllxd.hism.star.basic.service.model.SpmEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xiyong.lxy
 * @date 2020-10-12 16:51
 * v1/spm/spmInfo.do
 */
@Slf4j
@Service("spmService")
public class SpmServiceImpl implements SpmService {

    @Autowired
    private SpmMapper spmMapper;

    @Override public List<SpmEntity> listSpm() {
        return spmMapper.listSpmEntity();
    }

    @Override public Long setSpm(SpmEntity entity) {
        log.info("set param: {}", JSON.toJSONString(entity));
        if(entity.id==null || entity.id==0) {
            return spmMapper.insertSpm(entity);
        } else {
            return spmMapper.updateSpm(entity);
        }
    }

    @Override public SpmEntity getSpm(Long id) {
        return spmMapper.getSpm(id);
    }

    @Override
    public Boolean delSpm(Long id) {
        return spmMapper.deleteSpm(id.toString());
    }

}
